package main

import (
	"fmt"
	"reflect"
	"sanguo/node/common/orderMap"
)

var key string
var value int32
var value1 *TT

type TT struct {
	S string
}

func main() {
	oMap := orderMap.NewOrderMap()
	oMap.Add("test1", int32(5))
	oMap.Add("test2", 33)
	oMap.Add("test3", 66)
	fmt.Println(reflect.TypeOf(oMap.GetValueByIdx(0)), reflect.TypeOf(oMap.GetValueByKey("test2")))
	fmt.Println(oMap.GetValueByIdx(0), oMap.GetValueByKey("test1"))
	fmt.Println(oMap.GetValueByIdx(1), oMap.GetValueByKey("test2"))
	fmt.Println(oMap.GetValueByIdx(2), oMap.GetValueByKey("test3"))
	oMap.Del("test2")
	fmt.Println(oMap.GetValueByIdx(0), oMap.GetValueByKey("test1"))
	fmt.Println(oMap.GetValueByIdx(1), oMap.GetValueByKey("test2"))
	fmt.Println(oMap.GetValueByIdx(2), oMap.GetValueByKey("test3"))
	fmt.Println("--------------------")

	mm := map[string]int32{
		"test1": 5,
		"test2": 33,
		"test3": 66,
	}
	fmt.Println(mm["test2"], mm["ff"])
	fmt.Println("--------------------")

	oMap1 := orderMap.NewOrderMap()
	oMap1.Add("test1", &TT{
		S: "vvv1",
	})
	oMap1.Add("test2", 5)

	fmt.Println(reflect.TypeOf(oMap1.GetValueByIdx(0)), reflect.TypeOf(oMap1.GetValueByKey("test2")))
	fmt.Println(oMap1.GetValueByIdx(0), oMap1.GetValueByKey("test1"))
	fmt.Println(oMap1.GetValueByIdx(1), oMap1.GetValueByKey("test2"))
	fmt.Println("--------------------")

	oMap2 := orderMap.NewOrderMap()
	oMap2.Add("test1", int32(5))
	oMap2.Add("test2", 33)
	oMap2.Add("test3", 66)
	oMap2.Del("test2")
	oMap2.Del("test")
	oMap2.Add("test4", 44)
	fmt.Println(oMap2.GetValueByIdx(0), oMap2.GetValueByKey("test1"))
	fmt.Println(oMap2.GetValueByIdx(1), oMap2.GetValueByKey("test2"))
	fmt.Println(oMap2.GetValueByIdx(2), oMap2.GetValueByKey("test3"))
	fmt.Println(oMap2.GetValueByIdx(3), oMap2.GetValueByKey("test4"))
}
